function [ outdir ] = checkDir( sid, dirname, saveres )
%Check output dir
%   Make output dir name. Check is it exist, if not make it.
%
% Input
%   sid     - sample id: 's01', 's02', 's03', 's04', 't01', 'p01', 'p02'
%   dirname - last directory name
%   saveres - save result to disk 
%
% Output
%   outdir  - full name of output directory
%
% Syntax
%   [ outdir ] = checkDir( sid, dirname, saveres )
%
% History
% 23.11.12  Add function description

% Make output directory name
outdir = getpref('ebsdam','output_dir');
outdir = [outdir '\img\' sid '\' dirname];

% Make directory if save results to disk
if (saveres == 1)
    if ~exist(outdir, 'dir')
        mkdir(outdir);
    end
end

end

